<template>
  <div class="container">
    <el-dialog title="提示" :visible.sync="dialogVisible" width="30%" :before-close="close">
      <div>
        <el-radio label="1" v-model="checkData.chkState">通过</el-radio>
        <el-radio label="2" v-model="checkData.chkState">拒绝</el-radio>
        <p>审核意见：</p>
        <el-row>
          <el-input placeholder="请输入内容" v-model="checkData.chkRemarks" type="textarea" resize="none"></el-input>
        </el-row>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="$emit('close')">取 消</el-button>
        <el-button type="primary" @click="onSubmit">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { choiceCheck } from '@/api/hmmm/questions'
export default {
  name: 'QuestionCheck',
  props: {
    dialogVisible: {
      type: Boolean,
      required: true
    },
    questionItem: {
      type: Object,
      required: true
    }
  },
  data () {
    return {
      checkData: {
        // id: '',
        chkState: '1',
        chkRemarks: ''
      }
    }
  },
  methods: {

    async onSubmit () {
      // const data = await choiceCheck(this.checkData)
      if (this.checkData.chkRemarks.trim().length === 0) {
        return this.$message.warning('请输入审核意见')
      }
      console.log(this.questionItem)
      // this.checkData.id = this.questionItem.id
      const data = await choiceCheck({
        id: this.questionItem.id,
        chkState: this.checkData.chkState,
        chkRemarks: this.checkData.chkRemarks
      })
      this.$emit('close')
      this.$message.success('审核成功')
      console.log(data)
    },
    close () {
      this.$emit('close')
      this.checkData.chkRemarks = ''
    }
  }
}
</script>

<style scoped lang='less'>
</style>
